package utils.ui.adapter;

import java.util.List;

import com.ygk.bluepath.core.BActivity;

import android.annotation.SuppressLint;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class IndexPagerAdapter extends PagerAdapter {

	private List<View> mListViews;

	private BActivity mContext;

	public IndexPagerAdapter(BActivity context, List<View> mListViews) {
		this.mContext = context;
		this.mListViews = mListViews;
	}

	@Override
	public void destroyItem(View container, int position, Object object) {
		// super.destroyItem(container, position, object);
		((ViewPager) container).removeView(mListViews.get(position));
	}

	@Override
	public int getCount() {
		return mListViews.size();
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		return arg0 == (arg1);
	}

	@SuppressLint("NewApi")
	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		// 在此次加载图片
		// ......加载图片代码
		ImageView wel = new ImageView(mContext);
		switch (position) {
		case 0:

			// Tools.setimage(mContext, wel, "main01.jpg");
		//	mContext.imageLoader.displayImage("assets://main01.jpg", wel,ImageLoadOptions.view_pic());

			break;
		case 1:

			// Tools.setimage(mContext, wel, "main02.jpg");

		//	mContext.imageLoader.displayImage("assets://main02.jpg", wel,ImageLoadOptions.view_pic());
			break;
		case 2:

			// Tools.setimage(mContext, wel, "main03.jpg");

		//	mContext.imageLoader.displayImage("assets://main03.jpg", wel,ImageLoadOptions.view_pic());
			break;
		
		default:
			break;
		}

		// 加载页面
		container.addView(wel, 0);
		return wel;

	}

	@Override
	public void finishUpdate(View arg0) {
	}

	@Override
	public void restoreState(Parcelable arg0, ClassLoader arg1) {
	}

	@Override
	public Parcelable saveState() {
		return null;
	}

	@Override
	public void startUpdate(View arg0) {
	}

}